﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XDataBase.Demo.Data.Model;
using XLugia.Lib.XDataBase.Base.Model;
using XLugia.Lib.XDataBase.Base.Lib;
using XLugia.Lib.XDataBase.Engine.Lib;
using XDataBase.Demo.Common.Data;
using XDataBase.Demo.Data.Script;

namespace XDataBase.Demo.Data.Controller
{
    public class BaseController
    {
        #region properties
        public DatabaseConnector databaseConnector { get; set; }
        public Executor databaseExecutor { get; set; }
        public DatabaseScriptModel databaseScriptModel { get; set; }
        #endregion

        /// <summary>
        /// 主数据库
        /// </summary>
        public DatabaseConnector getDatabaseConnector()
        {
            return new DatabaseConnector()
                        {
                            connectionString = PublicVariables.getIns().serverConnectString,
                            commandTimeout = PublicVariables.serverConnectTimeout,
                            databaseType = PublicVariables.serverConnectType
                        };
        }

        public void executeSqlCommand(BaseScript baseScript)
        {
            var list = new List<DatabaseScriptModel>();

            //执行脚本
            list.Add(databaseScriptModel);

            databaseExecutor.executeSqlCommand(list);
        }
    }
}
